Telegram Group & Telegram Channel
Напишите линейную регрессию на Python с нуля

Это один из самых простых алгоритмов. Он включает следующие шаги:
1️⃣ Инициализация параметров.
2️⃣ Вычисление предсказаний.
3️⃣ Вычисление функции потерь.
4️⃣ Обновление параметров с помощью градиентного спуска.
5️⃣ Повторение до сходимости.
import numpy as np

class LinearRegression:
def __init__(self, learning_rate=0.01, n_iters=1000):
self.learning_rate = learning_rate
self.n_iters = n_iters

def fit(self, X, y):
n_samples, n_features = X.shape
self.weights = np.zeros(n_features)
self.bias = 0

for _ in range(self.n_iters):
model_preds = self.predict(X)
dw = (1 / n_samples) * np.dot(X.T, (model_preds - y))
db = (1 / n_samples) * np.sum(model_preds - y)

self.weights -= self.learning_rate * dw
self.bias -= self.learning_rate * db

def predict(self, X):
return np.dot(X, self.weights) + self.bias


#машинное_обучение
#программирование
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/ds_interview_lib/273
Create:
Last Update:

Напишите линейную регрессию на Python с нуля

Это один из самых простых алгоритмов. Он включает следующие шаги:
1️⃣ Инициализация параметров.
2️⃣ Вычисление предсказаний.
3️⃣ Вычисление функции потерь.
4️⃣ Обновление параметров с помощью градиентного спуска.
5️⃣ Повторение до сходимости.

import numpy as np

class LinearRegression:
def __init__(self, learning_rate=0.01, n_iters=1000):
self.learning_rate = learning_rate
self.n_iters = n_iters

def fit(self, X, y):
n_samples, n_features = X.shape
self.weights = np.zeros(n_features)
self.bias = 0

for _ in range(self.n_iters):
model_preds = self.predict(X)
dw = (1 / n_samples) * np.dot(X.T, (model_preds - y))
db = (1 / n_samples) * np.sum(model_preds - y)

self.weights -= self.learning_rate * dw
self.bias -= self.learning_rate * db

def predict(self, X):
return np.dot(X, self.weights) + self.bias


#машинное_обучение
#программирование

BY Библиотека собеса по Data Science | вопросы с собеседований


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/ds_interview_lib/273

View MORE
Open in Telegram


Библиотека собеса по Data Science | вопросы с собеседований Telegram | DID YOU KNOW?

Date: |

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”

How to Use Bitcoin?

n the U.S. people generally use Bitcoin as an alternative investment, helping diversify a portfolio apart from stocks and bonds. You can also use Bitcoin to make purchases, but the number of vendors that accept the cryptocurrency is still limited. Big companies that accept Bitcoin include Overstock, AT&T and Twitch. You may also find that some small local retailers or certain websites take Bitcoin, but you’ll have to do some digging. That said, PayPal has announced that it will enable cryptocurrency as a funding source for purchases this year, financing purchases by automatically converting crypto holdings to fiat currency for users. “They have 346 million users and they’re connected to 26 million merchants,” says Spencer Montgomery, founder of Uinta Crypto Consulting. “It’s huge.”

Библиотека собеса по Data Science | вопросы с собеседований from us


Telegram Библиотека собеса по Data Science | вопросы с собеседований
FROM USA